#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h> // 补充 exit 所需头文件

void intsig_handler(int signumber, siginfo_t *siginfo, void *empty) {
    printf("int_handler,mypid=%d\n", getpid());
}

int main() { // 明确返回类型
    int pid;
    char *arg[] = {"-l"};
    struct sigaction act;
    act.sa_sigaction = intsig_handler;
    act.sa_flags = SA_SIGINFO;
    if (sigaction(SIGINT, &act, NULL) < 0) {
        printf("install sigalert error\n");
    }
    printf("The parent pid=%d\n", getpid());
    pid = fork();
    if (pid < 0) {
        perror("fork failed!\n");
        exit(EXIT_FAILURE); // 规范使用 exit
    }
    printf("The return fork=%d\n", pid);
    while (1);
    return 0; // 添加 main 函数返回
}
